A=imread('C:\Rushi\SemesterVIII\ImageProcessing\lena.bmp');
A=double(A);
[row,col]=size(A);
sum = 0;
for  i = 1: row
    for j = 1: col
        sum = sum + A(i,j);
    end
end

% Calculate the mean of the image
display(sum);
mean=(sum)/(row*col);
display(mean);
% Calculate the variance and standard deviation of the image
diff=(A-mean).^2;
diffsquaresum = 0;
[newrow,newcol]=size(diff);
for  i = 1: newrow
    for j = 1: newcol
        diffsquaresum = diffsquaresum + A(i,j);
    end
end
var=diffsquaresum/((row*col)-1);
display(var);
standarddev=sqrt(var);
display(standarddev);
% Calculate the median of the image
R=reshape(A,[],1);
S=sort(R());
num=round((row*col)/2);
 
if((mod(row,2)==0) || (mod(col,2)==0) )
    median=(S(num)+S(num+1))/2;
else
    median=S(num);
end
display(median);
% Calculate covariance
newrow1 = 2;
newcol1 = 3;
rowsum = 0;
colsum = 0;
rowcolsum = 0;
for i = 1: newrow
    rowsum = rowsum + A(i,newcol1);
end
for i = 1: newcol
    colsum = colsum + A(newrow1,i);
end
rowmean = rowsum/row;
colmean = colsum/col;
for i = 1: row
   rowcolsum = ((A(i,newcol1)-rowmean)*(A(newrow1,i)-colmean));
end
cov = rowcolsum/(row*col);
display(cov)